import logger from "./logger";
import dotenv from "dotenv";
import fs from "fs";
import { AppConfigContainer } from './app.config';

export function readConfig() {
    if (fs.existsSync(".env")) {
        logger.debug("Using .env file to supply config environment variables");
        dotenv.config({ path: ".env" });
    } else {
        logger.debug("Using .env.example file to supply config environment variables");
        dotenv.config({ path: ".env.example" });  // you can delete this after you create your own .env file!
    }
    // if (!SESSION_SECRET) {
    //     logger.error("No client secret. Set SESSION_SECRET environment variable.");
    //     process.exit(1);
    // }
    for (const key in process.env) {
        const element = process.env[key];
        AppConfigContainer.set(key, element);
    }

}

// Anything else is treated as 'dev'
// export const ENVIRONMENT = process.env.NODE_ENV;
// export const SESSION_SECRET = process.env["SESSION_SECRET"];
// export const PORT = process.env["PORT"];
